package test;

import java.util.List;
import java.util.Map;

public class LogUtils {
	
	public static void printPerson(Person person) {
		System.out.println("person(uin=" + person.getUin() + ", name=" + person.getName() + ")");		
		printProperties(person.getProperties());		
	}
	
	public static void printProperty(Property property) {
		System.out.println("Property(" + property.getName() +", " + property.getCar() + ")");
		
		System.out.println("i=" + property.getI() + ", l=" + property.getL() + ", d=" + property.getD());
		System.out.println("map=" + (property.getM() != null ? property.getM().size() : 0));
		
		if (property.getM() != null) {
			for(Map.Entry<String, Car> entry: property.getM().entrySet()) {
				String name = entry.getKey();
				Car car = entry.getValue();
				System.out.println(name + " || " + car.getDesc() + "=" + car.getName());
			}
		}
		
		if (property.getCars() != null) {
			for (Car car: property.getCars()) {
				System.out.println("car(name=" + car.getName() + ", desc= " + car.getDesc() + ")");				
			}
		}
		if (property.getStocks() != null) {
			for(Stock stock: property.getStocks()) {
				printStock(stock);
			}
		}		
	}
	
	public static void printProperties(List<Property> properties) {
		for (Property property: properties) {
			printProperty(property);
		}		
	}
	
	public static void printStock(Stock stock) {
		System.out.println("stock(id=" + stock.getId() + ", count= " + stock.getCount() + ", desc=" + stock.getDesc() + ")");
	}
}